package ms.unicorn.dsl.serializer;

import com.google.inject.Inject;
import java.util.List;
import ms.unicorn.dsl.services.UnicornDSLGrammarAccess;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AlternativeAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.GroupAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;

@SuppressWarnings("all")
public abstract class AbstractUnicornDSLSyntacticSequencer extends AbstractSyntacticSequencer {

	protected UnicornDSLGrammarAccess grammarAccess;
	protected AbstractElementAlias match_IncludeStatement_SemicolonKeyword_2_q;
	protected AbstractElementAlias match_Statement_SemicolonKeyword_1_q;
	protected AbstractElementAlias match_XArray___FrameKeyword_1_1_0_1_LeftCurlyBracketKeyword_1_2_RightCurlyBracketKeyword_1_4___or___LeftSquareBracketKeyword_0_2_RightSquareBracketKeyword_0_4__;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (UnicornDSLGrammarAccess) access;
		match_IncludeStatement_SemicolonKeyword_2_q = new TokenAlias(false, true, grammarAccess.getIncludeStatementAccess().getSemicolonKeyword_2());
		match_Statement_SemicolonKeyword_1_q = new TokenAlias(false, true, grammarAccess.getStatementAccess().getSemicolonKeyword_1());
		match_XArray___FrameKeyword_1_1_0_1_LeftCurlyBracketKeyword_1_2_RightCurlyBracketKeyword_1_4___or___LeftSquareBracketKeyword_0_2_RightSquareBracketKeyword_0_4__ = new AlternativeAlias(false, false, new GroupAlias(false, false, new TokenAlias(false, false, grammarAccess.getXArrayAccess().getFrameKeyword_1_1_0_1()), new TokenAlias(false, false, grammarAccess.getXArrayAccess().getLeftCurlyBracketKeyword_1_2()), new TokenAlias(false, false, grammarAccess.getXArrayAccess().getRightCurlyBracketKeyword_1_4())), new GroupAlias(false, false, new TokenAlias(false, false, grammarAccess.getXArrayAccess().getLeftSquareBracketKeyword_0_2()), new TokenAlias(false, false, grammarAccess.getXArrayAccess().getRightSquareBracketKeyword_0_4())));
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		return "";
	}
	
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_IncludeStatement_SemicolonKeyword_2_q.equals(syntax))
				emit_IncludeStatement_SemicolonKeyword_2_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Statement_SemicolonKeyword_1_q.equals(syntax))
				emit_Statement_SemicolonKeyword_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_XArray___FrameKeyword_1_1_0_1_LeftCurlyBracketKeyword_1_2_RightCurlyBracketKeyword_1_4___or___LeftSquareBracketKeyword_0_2_RightSquareBracketKeyword_0_4__.equals(syntax))
				emit_XArray___FrameKeyword_1_1_0_1_LeftCurlyBracketKeyword_1_2_RightCurlyBracketKeyword_1_4___or___LeftSquareBracketKeyword_0_2_RightSquareBracketKeyword_0_4__(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_IncludeStatement_SemicolonKeyword_2_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_Statement_SemicolonKeyword_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ('[' ']') | ('frame' '{' '}')
	 */
	protected void emit_XArray___FrameKeyword_1_1_0_1_LeftCurlyBracketKeyword_1_2_RightCurlyBracketKeyword_1_4___or___LeftSquareBracketKeyword_0_2_RightSquareBracketKeyword_0_4__(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
